package com.nimt.hqgl_idea.global;

import com.nimt.hqgl_idea.util.ErrorEnum;
import com.nimt.hqgl_idea.util.ResponseBody;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import javax.servlet.http.HttpServletRequest;

@ControllerAdvice
@org.springframework.web.bind.annotation.ResponseBody
public class GlobalExceptionHandler {
    @ExceptionHandler(value=Exception.class) //该注解声明异常处理方法
    public ResponseBody exceptionHandler(HttpServletRequest request, Exception e){
        e.printStackTrace();
        return new ResponseBody(ErrorEnum.System_Exception);
    }
}
